home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / programming / other / flexcat / lib / cat2h_c.sd < prev    next >
Text File  |  1999-06-14  |  2KB  |  95 lines

  1.  
  2. /****************************************************************
  3.  
  4.    This file was created automatically by `%fv'
  5.    from "%f0"
  6.  
  7.    using Cat2h_c.sd 1.0 (23.05.97)
  8.  
  9.    Do NOT edit by hand!
  10.  
  11. ****************************************************************/
  12.  
  13. ##stringtype C
  14.  
  15. #ifdef __SASC
  16. #define __USE_SYSBASE 1
  17. #include <proto/exec.h>
  18. #include <proto/locale.h>
  19. #else
  20. #include <clib/exec_protos.h>
  21. #include <clib/locale_protos.h>
  22. #endif
  23.  
  24.  
  25. struct Library        *LocaleBase;
  26. static struct Catalog    *Catalog;
  27.  
  28.  
  29. /* No support for version number or other builtin language for now.
  30.  * Not often used (in my experience), and easy to add if you should
  31.  * need it.
  32.  *
  33.  * We open it at a high priority during autoinit (for SAS/C), to allow
  34.  * the use of GetString in lower priority autoinit code.
  35.  */
  36. #ifdef _DCC
  37. __autoinit
  38. #endif
  39. VOID
  40. #ifdef __SASC
  41. _STI_19000_GetCatalog( VOID )
  42. #else
  43. GetCatalog( VOID )
  44. #endif
  45. {
  46.     if( LocaleBase = OpenLibrary( "locale.library", 0 ) )
  47.     {
  48.         Catalog = OpenCatalogA( NULL, "%b.catalog", NULL );
  49.     }
  50. }
  51.  
  52.  
  53. #ifdef _DCC
  54. __autoexit
  55. #endif
  56. VOID
  57. #ifdef __SASC
  58. _STD_19000_FreeCatalog( VOID )
  59. #else
  60. FreeCatalog( VOID )
  61. #endif
  62. {
  63.     if( LocaleBase )
  64.     {
  65.         CloseCatalog( Catalog );
  66.         CloseLibrary( LocaleBase );
  67.     }
  68.  
  69.     Catalog = NULL;
  70.     LocaleBase = NULL;
  71. }
  72.  
  73.  
  74. STRPTR
  75. GetString( STRPTR str )
  76. {
  77.     ULONG    id;
  78.  
  79.     if( !str )
  80.     {
  81.         /* Avoid Enforcer hits... */
  82.         return( NULL );
  83.     }
  84.  
  85.     /* Avoid any problems regarding char not being unsigned */
  86.     id = ( ( ( UBYTE ) *str++ ) << 8 ) | ( ( UBYTE ) *str++ );
  87.  
  88.     if( Catalog )
  89.     {
  90.         str = GetCatalogStr( Catalog, id, str );
  91.     }
  92.  
  93.     return( str );
  94. }
  95.